#include <iostream>

#include "Comm.hpp"

int main()
{
    char buffer[1024];
    SetNonBlock(0);
    while (true)
    {
        ssize_t s = ::read(0, buffer, sizeof(buffer) - 1);
        if (s > 0)
        {
            buffer[s] = 0;
            std::cout << "Echo# " << buffer << std::endl;
        }
        else
        {
            if (errno == EWOULDBLOCK || errno == EAGAIN)
            {
                std::cout << "底层数据没有就绪，下次再试试吧！\n";
                sleep(1);
            }
            else
            {
                std::cout << "读取错误...." << std::endl;
                sleep(1);
            }
        }
    }

    return 0;
}